//检测数据类型
function type(type) {
    return function(obj) {
        return Object.prototype.toString.call(obj) === "[object " + type + "]";
    };
}

export const isString = type("String");
export const isObject = type("Object");
export const isArray = type("Array");
export const isNumber = type("Number");
export const isBoolean = type("Boolean");
export const isFunction = type("Function");

// 对象深拷贝
export const deepCopy = function(obj) {
    if (typeof obj != "object") {
        return obj;
    }
    if (obj === null) {
        return obj;
    }
    var newobj = {};
    for (var attr in obj) {
        newobj[attr] = deepCopy(obj[attr]);
    }
    return newobj;
};

// 获取当天最后一秒的时间戳
export const getLastTime = function(time) {
    return time + 24 * 60 * 60 * 1000 - 1;
};
